package com.example.administrator.dc.Activity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.administrator.dc.Bean.MyFollow;
import com.example.administrator.dc.Bean.MyfollowDatas;
import com.example.administrator.dc.R;
import com.example.administrator.dc.adapter.MyFollowAdapter;
import com.example.administrator.dc.model.FollowModel;
import com.example.administrator.dc.ui.MyDecoration;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MyFollowActivity extends AppCompatActivity {

private RecyclerView recyclerView;
    private String userid;
    private  MyFollowAdapter adapter;
    private List<MyfollowDatas> followlist;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_follow);
        initViews();
        Connect();


    }
    private void initViews()
    {
         recyclerView=(RecyclerView)findViewById(R.id.recycleview_id_myfollow);



    }
    private void Connect(){
               getUser();
     /*   FollowModel followModel=new FollowModel();
        Call<MyFollow> call=followModel.Followlist(userid);
        call.enqueue(new Callback<MyFollow>() {
            @Override
            public void onResponse(Call<MyFollow> call, Response<MyFollow> response) {
                if(response.body().getStatus()==1){
                    followlist=response.body().getData();
                    adapter=new MyFollowAdapter(MyFollowActivity.this,followlist);
                    LinearLayoutManager layoutManager=new LinearLayoutManager(MyFollowActivity.this);
                    //  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                    //GridLayoutManager gm = new GridLayoutManager(MyFollowActivity.this,1);
                    // 网格是的list布局   2列
                    recyclerView.setLayoutManager(new LinearLayoutManager(MyFollowActivity.this));
                    //recyclerView.setLayoutManager(gm);
                    // recyclerView.setAdapter(mAdapter);
                    // header.attachTo(recyclerView);
                    recyclerView.setLayoutManager(layoutManager);

                    recyclerView.setItemAnimator(new DefaultItemAnimator());
                    //这句就是添加我们自定义的分隔线
                    recyclerView.addItemDecoration(new MyDecoration(MyFollowActivity.this, MyDecoration.VERTICAL_LIST));
                    recyclerView.setAdapter(adapter);





                }

            }

            @Override
            public void onFailure(Call<MyFollow> call, Throwable t) {

            }
        });*/


    }

    private void getUser(){
        SharedPreferences sp = getSharedPreferences("UserInfo", MODE_PRIVATE);
        userid = sp.getString("user_id", "");


    }
}
